'use strict';

import React, { Component } from 'react';

import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Button,
  ScrollView
} from 'react-native';

import { StackNavigator } from 'react-navigation'
import SideMenu from 'react-native-side-menu';

import Home from './app/component/home'
import News from './app/component/news'
import Sidebar from './app/component/sidebar'


const image = require('./assets/menu.png');


const styles = StyleSheet.create({
  container: {
    // flex: 1,
    // justifyContent: 'center',
    // alignItems: 'center',
    // backgroundColor: '#FFFFFF',
  }
});


class ZhiHuIndex extends Component {
  render() {
    var navigation = this.props.navigation;

    return (
      <Home navigation={navigation} />
    );
  }
};


class HasSideBar extends Component {
  static navigationOptions = {
    header: null,
  };

  render() {
    var navigation = this.props.navigation;

    return (
      <SideMenu
        menu={<Sidebar />}
        openMenuOffset={100}
        edgeHitWidth={500}
      >
        <ZhiHuIndex navigation={navigation} />
      </SideMenu>
    );
  }
}



const SimpleApp = StackNavigator({
  Home: { screen: HasSideBar },
  News: { screen: News },
});




// MapView.js
// import MapView from './MapView'

// import { NativeModules, NativeComponent } from 'react-native';
// var MapView = NativeComponent.RNTMap;


import {
  requireNativeComponent,
  NativeModules
} from 'react-native'

var MapView = requireNativeComponent('RNTMap', null);
var Carousel = requireNativeComponent('RCTCarousel', null);


// var CarouselManaget = NativeModules.addEvent('Birthday Party', '4 Privet Drive, Surrey');

// var RCTBridgeTestManager = NativeModules.RCTBridgeTestManager;
// RCTBridgeTestManager.addEvent('Birthday Party', '4 Privet Drive, Surrey');


class wer extends Component {
  state = {
    ctext: 'default'
  }

  componentDidMount() {
    // alert('ddd')
  }

  render() {
    return (
      <View style={{
        flex: 1,
        backgroundColor: 'green'
      }} >
        <MapView
          pitchEnabled={false}
          onClickBanner = {(dic) => {
            alert(JSON.stringify(dic.nativeEvent))
            {/* alert('aaa'); */}

            console.log('====================================');
            console.log(dic.nativeEvent);
            console.log('====================================');
          }}

          style={{
            flex: 1
          }} />
        <Text style={{
          flex: 0
        }} >
          {this.state.ctext}
        </Text>
      </View>
    );
  }
}

class eeeee extends Component {
  state = {
    ctext: 'default'
  }

  componentDidMount() {
    // alert('ddd')
  }

  render() {
    return (
      <View style={{
        flex: 1,
        backgroundColor: 'green'
      }} >
        <Carousel
          imageURLStringsGroup = {[
            "http://wx3.sinaimg.cn/mw600/006GniB0ly1ficf607jjpj30qo0zkwkw.jpg",
            "http://wx2.sinaimg.cn/mw600/6cca1403ly1ficdulgyrzj20cf0gyt9n.jpg",
            "http://wx3.sinaimg.cn/mw600/006GniB0ly1ficf607jjpj30qo0zkwkw.jpg",
            "http://wx2.sinaimg.cn/mw600/6cca1403ly1ficdulgyrzj20cf0gyt9n.jpg",
            "http://wx3.sinaimg.cn/mw600/6cca1403ly1ficemrhebej20gl0feaay.jpg"
          ]}

          onClickBanner = { (dic) => {
            {/* alert(JSON.stringify(dic.nativeEvent)) */}

            let HelloWorld = NativeModules.HelloWorld;
            HelloWorld.sayHello('Hello World你好', function(err, arr) {
              console.log('====================================');
              console.log(JSON.stringify(arr));
              console.log('====================================');
            });
          } }

          style={{
            backgroundColor: 'red',
            position: 'absolute',
            height: 300,
            width: '100%',
            justifyContent: 'center',
            alignItems: 'center',
          }} />
        {/* <Text style={{
          flex: 0
        }} >
          {this.state.ctext}
        </Text> */}
      </View>
    );
  }
}




// 整体js模块的名称
AppRegistry.registerComponent('MyReactNativeApp', () => SimpleApp);